
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
/** 
COPYRIGHT (C) 2008 Piyusha Desai. All Rights Reserved.
* Read Licence.txt before using this application
*/
namespace SmsBuddy
{   /**
     * TEXT Message Options like forwarding.
     */
    public partial class SmsOptions : Form
    {
        Buddy buddy;
        public SmsOptions(Buddy buddy)
        {
            this.buddy = buddy;
            InitializeComponent();
        }

       
        private void chkForwardTextMessages_CheckStateChanged(object sender, EventArgs e)
        {
            EnableControls();
        }

        private void EnableControls()
        {
            DeleteLocalMessage.Enabled = ForwardTextMessages.Checked;
            AppendSenderInfo.Enabled = ForwardTextMessages.Checked;
            txtForwardNumber.Enabled = ForwardTextMessages.Checked;
            lnkChooseContact.Enabled = ForwardTextMessages.Checked;
        }

        private void TextMessageOptionsForm_Load(object sender, EventArgs e)
        {
            ForwardTextMessages.Checked = buddy.TextMessageOptions.ForwardingEnabled;
            DeleteLocalMessage.Checked = buddy.TextMessageOptions.DeleteLocalMessage;
            AppendSenderInfo.Checked = buddy.TextMessageOptions.AppendSenderInformation;
            txtForwardNumber.Text = buddy.TextMessageOptions.ForwardNumber;

            EnableControls();
        }

        private void mnuCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void mnuOk_Click(object sender, EventArgs e)
        {
            buddy.TextMessageOptions.AppendSenderInformation = AppendSenderInfo.Checked;
            buddy.TextMessageOptions.DeleteLocalMessage = DeleteLocalMessage.Checked;
            buddy.TextMessageOptions.ForwardingEnabled = ForwardTextMessages.Checked;
            buddy.TextMessageOptions.ForwardNumber = txtForwardNumber.Text;
            DialogResult = DialogResult.OK;
            Close();
        }

        private void lnkChooseContact_Click(object sender, EventArgs e)
        {
            
            ChooseContactDialog dlg = new ChooseContactDialog();
            dlg.ChooseContactOnly = false;
            dlg.RequiredProperties = new ContactProperty[] { ContactProperty.AllPhone };
            
            // put selected contact user
            if (dlg.ShowDialog() == DialogResult.OK)
            {
               
                txtForwardNumber.Text = dlg.SelectedPropertyValue;
            }

        }

      

    }
}